package com.example.duomeitijuhe.db;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;


public class UserDatabaseHelper extends SQLiteOpenHelper {
    public static final String CREATE_ACCOUNT = "create table Account ("
            +"id integer primary key autoincrement,"
            +"account text,"
            +"password text)";

    public static final String CREATE_TOKEN = "create table Token ("
            + "id integer primary key autoincrement,"
            + "platform text,"
            + "userid text,"
            + "token text)";

    public static final String CREATE_INTERNET_DATA = "create table InternetData("
            + "id integer primary key autoincrement,"
            + "userId text,"
            + "weiboId text,"
            + "senderId text,"
            + "senderName text,"
            + "senderIconUrl text,"
            + "sendTime text,"
            + "content text,"
            + "contentPictureUrl text,"
            + "isRetransmit integer,"
            + "originalSenderId text,"
            + "originalSenderName text,"
            + "originalSenderIconUrl text,"
            + "originalContent text,"
            + "originalPictureUrl text)";

    private Context mContext;
    public UserDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
        super(context,name,factory,version);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_ACCOUNT);
        db.execSQL(CREATE_TOKEN);
        db.execSQL(CREATE_INTERNET_DATA);
        //Toast.makeText(mContext,"创建成功！！！",Toast.LENGTH_SHORT).show();
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        switch (oldVersion){
            case 1:
                db.execSQL(CREATE_TOKEN);
            default:
        }
    }
}
